package thread;

// 继承 Thread, 重写 run, 使用匿名内部类
public class demo3 {

    public static void main(String[] args) throws InterruptedException {
        Thread thread = new Thread(){
            @Override
            public void run() {
                for (int i = 0; i < 10; i++) {
                    System.out.println("匿名内部类的子线程类被执行了 " + i);
                    try {
                        Thread.sleep(1000);
                    } catch (InterruptedException e) {
                        throw new RuntimeException(e);
                    }
                }
            }
        };

        thread.start();

        for (int i = 0; i < 10; i++) {
            System.out.println("主线程main方法被执行了 " + i);
            Thread.sleep(1000);
        }
    }
}
